<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  @body_classes << 'hide-content-while-scripts-not-loaded right-side-optional'
  content_for :page_title, join_title(t('#titles.announcements', "Announcements"), @context.name)
  feed_code = @context_enrollment.try(:feed_code) || (@context.available? && @context.feed_code)
  js_bundle :announcements_index
  css_bundle :discussions_list
%>
<% content_for :auto_discovery do %>
  <% feed_key = nil
     if @context_enrollment
       feed_key = @context_enrollment.feed_code
     elsif can_do(@context, @current_user, :manage)
       feed_key = @context.feed_code
     elsif @context.available? && @context.respond_to?(:is_public) && @context.is_public
       feed_key = @context.asset_string
     end
     if feed_key
       if @context.is_a?(Course) %>
         <%= auto_discovery_link_tag(:atom, feeds_announcements_format_path(feed_key, :atom), {:title => t(:feed_title_course, "Course Announcements Atom Feed")}) %>
         <%= auto_discovery_link_tag(:rss, feeds_announcements_format_path(feed_key, :rss), {:title => t(:podcast_title_course, "Course Announcements Podcast Feed")}) %>
  <%   elsif @context.is_a?(Group) %>
         <%= auto_discovery_link_tag(:atom, feeds_announcements_format_path(feed_key, :atom), {:title => t(:feed_title_group, "Group Announcements Atom Feed")}) %>
         <%= auto_discovery_link_tag(:rss, feeds_announcements_format_path(feed_key, :rss), {:title => t(:podcast_title_group, "Group Announcements Podcast Feed")}) %>
  <%   end
     end %>
<% end %>

